# syntax=docker/dockerfile:1

# ---------- 构建阶段 ----------
FROM docker.m.daocloud.io/library/maven:3.9.6-eclipse-temurin-8 AS build
WORKDIR /workspace
COPY pom.xml .
RUN mvn -B -U -q -Dmaven.test.skip=true -DskipTests dependency:go-offline
COPY src ./src
RUN mvn -B clean package -DskipTests

# ---------- 运行阶段 ----------
# ⚠️ 使用你本地已有的 JDK17 镜像
FROM eclipse-temurin:17-jdk

WORKDIR /app
ENV JAVA_OPTS="" \
    SPRING_PROFILES_ACTIVE=prod \
    TZ=Asia/Shanghai

COPY --from=build /workspace/target/*.jar app.jar
EXPOSE 8080
ENTRYPOINT ["sh", "-c", "java $JAVA_OPTS -jar /app/app.jar"]
